home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
misc
/
emu
/
ATUtilities.lha
/
ATUtilities
/
man.c
< prev
next >
Wrap
C/C++ Source or Header
|
2000-09-29
|
10KB
|
404 lines
/* ******************************************************************* */
/* ** ** */
/* ** ATUtilities Utility Manager ** */
/* ** Copright (C) 1992-1994 by Thomas Dreibholz ** */
/* ** All rights reserved ** */
/* ** ** */
/* ******************************************************************* */
#include "ATUtilities.h"
UBYTE *PrefsName="AT:Prefs/UtilityManager.prefs";
UBYTE *ManagerPort="--* The ATUtilities Utility Manager *--";
UBYTE *HelpName="AT:Help/UtilityManager.help";
struct Library *ATUtilitiesBase;
struct Library *GfxBase;
struct Library *IntuitionBase;
struct MsgPort *Port;
struct TextFont *opal;
struct ATUtility ATUtility[13];
APTR MenuStrip;
UWORD Count;
VOID OpenAll();
VOID CloseAll();
VOID Editieren();
VOID ShowInfo();
BYTE Zeigen();
VOID main()
{
REGISTER BYTE ende;
OpenAll();
ende=0;
do
{
ende=Zeigen();
if(ende>0) Editieren(ende-1);
} while(ende!=0);
CloseAll();
}
VOID OpenAll()
{
REGISTER UWORD i;
register struct FileHandle *fh;
register struct MsgPort *p;
IntuitionBase=OpenLibrary("intuition.library",0L);
GfxBase=OpenLibrary("graphics.library",0L);
if((IntuitionBase==NULL)||(GfxBase==NULL)) CloseAll();
ATUtilitiesBase=OpenLibrary("at-utilities.library",0L);
if(ATUtilitiesBase==NULL)
{
printf("Kann ATUtilities-Library nicht öffnen.\n");
CloseAll();
}
p=FindPort(ManagerPort);
if(p!=NULL)
{
InfoRequest("Der Utility-Manager ist bereits aktiv!");
CloseAll();
}
Port=CreatePort(ManagerPort,0L);
if(Port==NULL)
{
ErrorRequest(ERROR_PORT);
CloseAll();
}
opal=GetOpalFont();
for(i=0;i<=12;i++)
{
strcpy(&ATUtility[i].PortName,"");
strcpy(&ATUtility[i].Name,"");
}
Count=0;
fh=Open(PrefsName,MODE_OLDFILE);
if(fh!=NULL)
{
Read(fh,&Count,2L);
if(Count<=12)
{
for(i=0;i<=Count;i++)
{
Read(fh,&ATUtility[i],sizeof(struct ATUtility));
}
}
else
{
Count=0;
}
Close(fh);
}
if(Count==0)
{
strcpy(&ATUtility[0].Name,"ATUtilities Library");
strcpy(&ATUtility[0].PortName,"");
}
}
VOID CloseAll()
{
if(ATUtilitiesBase) CloseLibrary(ATUtilitiesBase);
if(GfxBase) CloseLibrary(GfxBase);
if(IntuitionBase) CloseLibrary(IntuitionBase);
if(Port) DeletePort(Port);
exit(0);
}
BYTE Zeigen()
{
BYTE b;
UWORD i,j,Code;
BOOL ende;
ULONG Class;
struct Window *win;
struct RastPort *rp;
struct Gadget *gad;
struct IntuiMessage *msg;
struct FileHandle *fh;
i=(Count+1)*14+29+BorderHeight(); b=0;
win=CreateStdWindow("ATUtility Manager - Übersicht",
25,25,590,i,
CLOSEWINDOW|GADGETUP|MENUPICK,
WINDOWCLOSE|WINDOWDRAG|WINDOWDEPTH|ACTIVATE|GIMMEZEROZERO);
if(win!=NULL)
{
rp=win->RPort;
SetFont(rp,opal);
MenuStrip=BuildMenuStrip(win,AUTOFRONTPEN,AUTOBACKPEN);
if(MenuStrip!=NULL)
{
AddMenu(MenuStrip,"Datei",5,120);
AddItem(MenuStrip,"Informationen zum Programm",300,'I',TRUE,TRUE);
AddItem(MenuStrip,"Hilfe zum Programm",300,'H',TRUE,TRUE);
AddItem(MenuStrip,GetOpalLine(),300,0,FALSE,FALSE);
AddItem(MenuStrip,"Programm beenden",300,'Q',TRUE,TRUE);
UseMenuStrip(MenuStrip);
}
CreateBoolGadget(win,10,5,210,12,"Einstellungen Okay",1000);
CreateBoolGadget(win,225,5,50,12,"Neu",3000);
CreateBoolGadget(win,280,5,50,12,"Hilfe",4000);
CreateBoolGadget(win,340,5,240,12,"Information",2000);
for(i=0;i<=Count;i++)
{
j=25+(i*14);
if(i!=Count)
{
CreateBoolGadget(win,10,j,20,12,"!",i+1);
CreateBoolGadget(win,35,j,90,12,"Aufrufen",100+i);
CreateBoolGadget(win,130,j,90,12,"Entfernen",200+i);
}
CreateBoolGadget(win,225,j,50,12,"Info",300+i);
CreateBoolGadget(win,280,j,50,12,"Hilfe",400+i);
DrawNTextBorder(win,340,j,240,12,&ATUtility[i].Name);
}
ende=FALSE;
while(ende==FALSE)
{
WaitPort(win->UserPort);
msg=GetMsg(win->UserPort);
Class=msg->Class;
Code=msg->Code;
gad=msg->IAddress;
ReplyMsg(msg);
switch(Class)
{
case CLOSEWINDOW:
ende=TRUE; b=0;
break;
case MENUPICK:
i=MENUNUM(Code);
j=ITEMNUM(Code);
if(i==0)
{
switch(j)
{
case 0:
ende=TRUE; b=0;
break;
case 2:
Help(HelpName,0);
break;
case 3:
ShowInfo();
break;
}
}
break;
case GADGETUP:
i=gad->GadgetID;
if(i<100)
{
ende=TRUE;
b=(BYTE)i;
}
else if(i<200) Utility(&ATUtility[i-100].PortName,UTILITY_CALL);
else if(i<300) Utility(&ATUtility[i-200].PortName,UTILITY_QUIT);
else if(i<400)
{
if(i!=300+Count)
{
Utility(&ATUtility[i-300].PortName,UTILITY_INFO);
}
else
{
LibraryInfo();
}
}
else if(i<500)
{
if(i!=400+Count)
{
Utility(&ATUtility[i-400].PortName,UTILITY_HELP);
}
else
{
Help(HelpName,0);
}
}
else if(i==1000)
{
fh=Open(PrefsName,MODE_NEWFILE);
if(fh!=NULL)
{
Write(fh,&Count,2L);
for(i=0;i<=Count;i++)
{
Write(fh,&ATUtility[i],sizeof(struct ATUtility));
}
Close(fh);
}
ende=TRUE;
}
else if(i==3000)
{
if(Count==12)
{
MultiRequest("Es können nur maximal 12 Utilities",
"Verwaltet werden!","Okay",NULL);
}
else
{
b=120;
ende=TRUE;
}
}
else if(i==4000)
{
Help(HelpName,0);
}
else
{
ShowInfo();
}
break;
}
}
ClearMenuStrip(win);
DeleteStdWindow(win);
RemoveMenuStrip(MenuStrip);
}
return(b);
}
VOID Editieren(num)
UBYTE num;
{
REGISTER UWORD i;
REGISTER BOOL ende;
REGISTER ULONG Class;
REGISTER UBYTE *name,*port;
register struct Window *win;
register struct RastPort *rp;
register struct Gadget *gad;
register struct IntuiMessage *msg;
win=CreateStdWindow("ATUtility Manager - Utility ändern/hinzufügen",
75,75,450,62+BorderHeight(),
CLOSEWINDOW|GADGETUP,
WINDOWCLOSE|WINDOWDRAG|WINDOWDEPTH|ACTIVATE|GIMMEZEROZERO);
if(win!=NULL)
{
rp=win->RPort;
SetFont(rp,opal);
CreateBoolGadget(win,10,5,100,12,"Okay",1);
CreateBoolGadget(win,115,5,100,12,"Abbruch",2);
if(num!=119)
{
CreateBoolGadget(win,305,5,120,12,"Entfernen",3);
name=&ATUtility[num].Name;
port=&ATUtility[num].PortName;
}
else
{
name="";
port="";
}
SelectStdFPen(rp);
WriteText(rp,20,33,"Name:");
WriteText(rp,20,52,"Port-Name:");
name=CreateStringGadget(win,115,24,310,12,name,42,10);
port=CreateStringGadget(win,115,43,310,12,port,42,20);
ende=FALSE;
while(ende==FALSE)
{
WaitPort(win->UserPort);
msg=GetMsg(win->UserPort);
Class=msg->Class;
gad=msg->IAddress;
ReplyMsg(msg);
switch(Class)
{
case CLOSEWINDOW:
ende=TRUE;
break;
case GADGETUP:
i=gad->GadgetID;
switch(i)
{
case 1:
if(num==119)
{
strcpy(&ATUtility[Count+1].Name,&ATUtility[Count].Name);
strcpy(&ATUtility[Count+1].PortName,&ATUtility[Count].PortName);
num=Count;
Count++;
}
strcpy(&ATUtility[num].Name,name);
strcpy(&ATUtility[num].PortName,port);
ende=TRUE;
break;
case 2:
ende=TRUE;
break;
case 3:
for(i=num;i<Count;i++)
{
strcpy(&ATUtility[i].Name,&ATUtility[i+1].Name);
strcpy(&ATUtility[i].PortName,&ATUtility[i+1].PortName);
}
Count--;
ende=TRUE;
break;
}
break;
}
}
DeleteStdWindow(win);
}
}
struct InfoItem ii5=
{
1,1,
"Service",
"",
"Haben Sie Anregungen oder",
"Verbesserungswünsche?",
"",
"",
"Schreiben Sie an:",
"",
"Thomas Dreibholz",
"Molbachweg 7",
"D-51674 Wiehl",
"West Germany"
};
struct Info idata=
{
1,
&ii5,
};
/* Informationen anzeigen */
VOID ShowInfo()
{
ExtInformationBox(NULL,
"ATUtilities Utility-Manager - Information",
"$VER: Utility-Manager - Version 4.0",
"Copyright (C) 1992-1994 by",
"Thomas Dreibholz",
"All rights reserved.",
"AT:Icons/Manager",
&idata);
}